<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>宁波数字电视资源普查系统</title>

    <!-- Mobile viewport optimisation -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- (en) Add your meta data here -->
    <!-- (de) Fuegen Sie hier ihre Meta-Daten ein -->

    <link href="{{ url_for('static',filename='css/flexible-grids.css') }}" rel="stylesheet" type="text/css" />
    <!--[if lte IE 7]>
	<link href="{{ url_for('static',filename='yaml/core/iehacks.css') }}" rel="stylesheet" type="text/css" />
	<![endif]-->


    <!--[if lt IE 9]>
	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->

    <link rel="stylesheet" href="{{ url_for('static',filename='lib/jquery.cluetip/jquery.cluetip.css') }}" type="text/css">
    <link rel="stylesheet" href="{{ url_for('static',filename='lib/jquery-ui/css/smoothness/jquery-ui-1.9.0.custom.min.css') }}" type="text/css">

    <script type=text/javascript src="{{ url_for('static', filename='lib/jquery-1.8.2.min.js') }}"></script>

    <script type=text/javascript>
        $SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
    </script>
    <script type="text/javascript" src="{{ url_for('static',filename='lib/jquery.cluetip/jquery.cluetip.all.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static',filename='lib/jquery-ui/js/jquery-ui-1.9.0.custom.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static',filename='lib/jquery-ui/js/jquery.ui.datepicker-zh-CN.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static',filename='lib/jquery.ui.autocomplete.html.js') }}"></script>

    {% block jquerypluginlib %}{% endblock jquerypluginlib %}


    <link href="{{ url_for('static',filename='css/style.css') }}" rel="stylesheet" type="text/css" />
    <script type=text/javascript>
        $(function() {
            {#            $[ "ui" ][ "autocomplete" ].prototype["_renderItem"] = function( ul, item) {#}
            {#                return $( "<li></li>" )#}
            {#                        .data( "item.autocomplete", item )#}
            {#                        .append( $( "<a></a>" ).html( item.label ) )#}
            {#                        .appendTo( ul );#}
            {#            };#}

            $(".datepicker").datepicker();
            var addrcache = {};
            var commcache={};
            {#            var linecache={};#}
            function acsearch(classname,jsonurl,cachedata){
                $(classname).autocomplete({
                                              html:true,
                                              position: {  collision: "flip"  },
                                              minLength: 1,
                                              source: function( request, response ) {
                                                  var term = request.term;
                                                  if ( term in cachedata ) {
                                                      response( cachedata[ term ] );
                                                      return;
                                                  }

                                                  $.getJSON( $SCRIPT_ROOT+jsonurl, request, function( data, status, xhr ) {
                                                      cachedata[ term ] = data.result;
                                                      response( data.result );
                                                  });
                                              },
                                              select:function(event,ui){
                                                  $(this).prev().val(ui.item.id);
                                              },
                                              change: function( event, ui ) {
                                                  if ( !ui.item ) {
                                                      // no item selected
                                                      $(this).prev().val('0');
                                                      $(this).css('color','red');
                                                  }else{
                                                      $(this).css('color','');
                                                  }
                                              }
                                          });
            }
            acsearch('.ac_addr','{{ url_for('json_addr') }}',addrcache);
            acsearch('.ac_comm','{{ url_for('json_comm') }}',commcache);
            {#            acsearch('.ac_line','{{ url_for('json_line') }}',linecache);#}

            {#            $(".ac_port").autocomplete({#}
            {#                html:true,#}
            {#                position: {  collision: "flip"  },#}
            {#                minLength: 1,#}
            {#                source: function( request, response ) {#}
            {#                    var term = request.term;#}
            {#                    if ( term in cache ) {#}
            {#                        response( cache[ term ] );#}
            {#                        return;#}
            {#                    }#}
            {##}
            {#                    $.getJSON( "/json_port", request, function( data, status, xhr ) {#}
            {#                        cache[ term ] = data.result;#}
            {#                        response( data.result );#}
            {#                    });#}
            {#                },#}
            {#                select:function(event,ui){#}
            {#                    $(this).prev().val(ui.item.id);#}
            {#                },#}
            {#                change: function( event, ui ) {#}
            {#                    if ( !ui.item ) {#}
            {#                        // no item selected#}
            {#                        $(this).prev().val('0');#}
            {#                    }#}
            {#                }#}
            {#            });#}
            $("#closeflashmessage").click(function(){
                $("#flashmessage").hide();
            });
        });
    </script>

</head>
<body>
<ul class="ym-skiplinks">
    <li><a class="ym-skip" href="#nav">Skip to navigation (Press Enter)</a></li>
    <li><a class="ym-skip" href="#main">Skip to main content (Press Enter)</a></li>
</ul>

<header>
    <div class="ym-wrapper">
        <div class="ym-wbox">
            <h1>宁波数字电视资源普查系统</h1>
        </div>
    </div>
</header>
<nav id="nav">
    <div class="ym-wrapper">
        <div class="ym-hlist">
            <ul>
                <li{% if request.path=='/' %} class="active"{% endif %}><a href="/"><strong>首页</strong></a></li>
                <li{% if request.path=='/topo' %} class="active"{% endif %}><a href="/topo"><strong>拓扑列表</strong></a></li>
                <li{% if request.path=='/dizhi' %} class="active"{% endif %}><a href="/dizhi"><strong>地址录入</strong></a></li>
                <li{% if request.path=='/res' %} class="active"{% endif %}><a href="/res"><strong>资源录入</strong></a></li>
                <li{% if request.path=='/comm' %} class="active"{% endif %}><a href="/comm"><strong>小区录入</strong></a></li>
            </ul>
            <form class="ym-searchform" action="{{ url_for('index') }}" method="post">
                <input type="hidden" name="addrid" value="{{ addrid or '0' }}" />
                <input class="ac_addr ym-searchfield" name="addr" id="addr" class="ym-searchfield" type="search" placeholder="地址" value="{{ addr or '' }}" />
                <input class="ym-searchbutton" type="submit" value="搜索" />
            </form>
        </div>
    </div>
</nav>
<div id="main">
    <div class="ym-wrapper">
        <div class="ym-wbox">
            {% if get_flashed_messages() %}
                <section class="box error" id="flashmessage">
                    <a href="#" id="closeflashmessage" style="float: right">X</a>
                    {% for message in get_flashed_messages() %}
                        <div class=flash>{{ message }}</div>
                    {% endfor %}
                </section>
            {% endif %}
            {% block main %}{% endblock main %}
        </div>
    </div>
</div>

<footer>
    <div class="ym-wrapper">
        <div class="ym-wbox">
            <p>© Company 2012 &ndash; Design based on gongqf</p>
        </div>
    </div>
</footer>

<!-- full skip link functionality in webkit browsers -->
<script src="{{ url_for('static',filename='yaml/core/js/yaml-focusfix.js') }}"></script>
</body>
</html>
